<?php 
	session_start(); 
	if (!$_SESSION["id_no"])
    {
        Header("Location: index.php");
    }
	else{
		if ($_SESSION['account_type']=='root'){
			$header="secured/header_login";
		}
		else{ 
			$header="header";
		}
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ralimo System Panel</title>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" title="default" />
<link rel="stylesheet" href="css/jquery-ui-1.8.21.custom.css" type="text/css" media="screen" title="default" />
<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="css/pro_dropline_ie.css" />
<![endif]-->

<!--  jquery core -->
<script src="js/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>


<!--  checkbox styling script -->
<script src="js/jquery/ui.core.js" type="text/javascript"></script>
<script src="js/jquery/ui.checkbox.js" type="text/javascript"></script>
<script src="js/jquery/jquery.bind.js" type="text/javascript"></script>
<script src="js/jquery/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery/geocoder.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3&libraries=places&key=AIzaSyDe8jbfLwcLgh5ERFqcJUGDM_svl2foezQ&sensor=false"></script>

<script type="text/javascript">
$(function(){
	$('input').checkBox();
	$('#toggle-all').click(function(){
 	$('#toggle-all').toggleClass('toggle-checked');
	$('#mainform input[type=checkbox]').checkBox('toggle');
	return false;
	});
});
</script>  

<![if !IE 7]>

<!--  styled select box script version 1 -->
<script src="js/jquery/jquery.selectbox-0.5.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
	$('.styledselect').selectbox({ inputClass: "selectbox_styled" });
});
</script>
 

<![endif]>

<!--  styled select box script version 2 --> 
<script src="js/jquery/jquery.selectbox-0.5_style_2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
	$('.styledselect_form_1').selectbox({ inputClass: "styledselect_form_1" });
	$('.styledselect_form_2').selectbox({ inputClass: "styledselect_form_2" });
});
</script>

<!--  styled select box script version 3 --> 
<script src="js/jquery/jquery.selectbox-0.5_style_2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
	$('.styledselect_pages').selectbox({ inputClass: "styledselect_pages" });
});
</script>

<!--  styled file upload script --> 
<script src="js/jquery/jquery.filestyle.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
  $(function() {
      $("input.file_1").filestyle({ 
          image: "images/forms/choose-file.gif",
          imageheight : 21,
          imagewidth : 78,
          width : 310
      });
  });
</script>

<!-- Custom jquery scripts -->
<script src="js/jquery/custom_jquery.js" type="text/javascript"></script>
 
<!-- Tooltips -->
<script src="js/jquery/jquery.tooltip.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
	$('a.info-tooltip ').tooltip({
		track: true,
		delay: 0,
		fixPNG: true, 
		showURL: false,
		showBody: " - ",
		top: -35,
		left: 5
	});
});
</script> 


<!--  date picker script -->
<link rel="stylesheet" href="css/datePicker.css" type="text/css" />
<script src="js/jquery/date.js" type="text/javascript"></script>
<script src="js/jquery/jquery.datePicker.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
        $(function()
{

// initialise the "Select date" link
$('#date-pick')
	.datePicker(
		// associate the link with a date picker
		{
			createButton:false,
			startDate:'01/01/2005',
			endDate:'31/12/2020'
		}
	).bind(
		// when the link is clicked display the date picker
		'click',
		function()
		{
			updateSelects($(this).dpGetSelected()[0]);
			$(this).dpDisplay();
			return false;
		}
	).bind(
		// when a date is selected update the SELECTs
		'dateSelected',
		function(e, selectedDate, $td, state)
		{
			updateSelects(selectedDate);
		}
	).bind(
		'dpClosed',
		function(e, selected)
		{
			updateSelects(selected[0]);
		}
	);
	
var updateSelects = function (selectedDate)
{
	var selectedDate = new Date(selectedDate);
	$('#d option[value=' + selectedDate.getDate() + ']').attr('selected', 'selected');
	$('#m option[value=' + (selectedDate.getMonth()+1) + ']').attr('selected', 'selected');
	$('#y option[value=' + (selectedDate.getFullYear()) + ']').attr('selected', 'selected');
}
// listen for when the selects are changed and update the picker
$('#d, #m, #y')
	.bind(
		'change',
		function()
		{
			var d = new Date(
						$('#y').val(),
						$('#m').val()-1,
						$('#d').val()
					);
			$('#date-pick').dpSetSelected(d.asString());
		}
	);

// default the position of the selects to today
var today = new Date();
updateSelects(today.getTime());

// and update the datePicker to reflect it...
$('#d').trigger('change');
});
</script>

<!-- MUST BE THE LAST SCRIPT IN <HEAD></HEAD></HEAD> png fix -->
<script src="js/jquery/jquery.pngFix.pack.js" type="text/javascript"></script>
<script type="text/javascript">
	var city = "<?php if(isset($_GET['city'])){ echo $_GET['city']; } ?>";
	$(document).ready(function(){
		$(document).pngFix( );
		
		$(".result-header").append( 
					"<span style='font-size: 20px; font-weight: bold; '>Rates for: " + city + "</span><br><br>"+
					"<hr>" 
		);
		
		$.post("query/query-data.php", {search: city, flag: "ralimo"}, function(data){
			var txt = '';
			$.each(data, function(key, val){
				txt += val;
			});
			
			txt = txt.replace(/[`!#$%^&()+\=?;'<>\{\}\[\]\\\/]/gi, '');
			txt = txt.replace(/","/g, "*");
			txt = txt.replace(/"/g, "");
			
			var result = txt.split("|");
			var arr= "";
			var arrservices ="";
			var arrremarks = "";
			var vehicletype = [];
			var vehiclemodel = [];
			var capacity = [];
			var cancellationpolicy = [];
			var destination = [];
			var hourlydestination = [];
			var currency = [];
			var rate = [];
			
			var test = [];
			$.each(result, function(key, val){
				//console.log(key + ":" + val);
				if( val ){
					if( key != 0 ){
						val = val.replace("*", "");
					}
					arr = val.split("*");
					//console.log(val);
													
					vehicletype.push(arr[2]);
					destination.push(arr[7]);
				
					
					
					// $(".result-body").append(
						// "<b>" + arr[1].toUpperCase() + ":</b><br>" +
						// "<b>Vehicle Models: </b>" + arr[2] + "<br>" +
						// "Capacity: " + arr[3] + "<br>" 
					// );
					

				}
			});
				
/***process data vehicletype***/
				var b = {};
				for (var i = 0; i < vehicletype.length; i++) {
					b[vehicletype[i]] = vehicletype[i];
				}
				var vehicletypes = [];
				for (var key in b) {
					vehicletypes.push(key);
				}
/***process data vehicletype***/

/***process data vehiclemodel and capacity***/				
			$.post("query/query-data.php", {search: city, flag: "ralimocapacity"}, function(data){
				var txt = '';
				$.each(data, function(key, val){
					txt += val;
				});
				
				txt = txt.replace(/[`~!#$%^&()+\=?;'<>\{\}\[\]\\\/]/gi, '');
				txt = txt.replace(/","/g, "*");
				txt = txt.replace(/"/g, "");
				
				var result = txt.split("|");
				
				$.each(result, function(key, val){
				//console.log(key + ":" + val);
				if( val ){
					if( key != 0 ){
						val = val.replace("*", "");
					}
					arr = val.split("*");
					vehiclemodel.push(arr[1]);
					capacity.push(arr[2]);
					cancellationpolicy.push(arr[3]);
					test.push(arr[3]);
				}
				});
				for(i = 0; i < test.length; i++){
					console.log("<br /> Element " + i + " = " + test[i]); 
				}
				
/***process data vehiclemodel and capacity***/

/***process data destination***/
				var tmp = " ";
				$.each(destination, function(key, val){
					console.log(key+":"+val);
					tmp += val + "<br>";
				});
				var dest = tmp.split("~");
/***process data destination***/
				
/***process data services and remarks***/				
			$.post("query/query-data.php", {search: city, flag: "ralimoothers"}, function(data){
				var txt = '';
				$.each(data, function(key, val){
					txt += val;
				});
				
				txt = txt.replace(/[`~!#$%^&()+\=?;'\{\}\[\]\\\/]/gi, '');
				txt = txt.replace(/","/g, "*");
				txt = txt.replace(/"/g, "");
				
				var result = txt.split("|");
				
				$.each(result, function(key, val){
				//console.log(key + ":" + val);
				if( val ){
					if( key != 0 ){
						val = val.replace("*", "");
					}
					arrservices = val.split("*");
					
				}
				
				});
/***process data services and remarks***/	
								
/**display to body**/		
				for(var j = 0; j < vehicletypes.length; j++){
					//dest[j] = dest[j].replace(/[*]/g, "<br>");
					$(".result-body").append(
						"<b>Vehicle Type: </b>" + vehicletypes[j] + "<br>" +
						"<b>Vehicle Model: </b>" + vehiclemodel[j] + "<br>" +
						"<b>Capacity: </b> " + capacity[j] +  "<br>" +
						"" + dest[j] + "<br>" +
						"<b>Cancellation Policy: </b>" + cancellationpolicy[j] + "<br>" +
						" ----------------------------------------------------------------------- <br><br>" 
					);
				}
				
				for(var j = 0; j < arrservices.length; j++){
					$(".result-body").append(
						""+ arrservices[j] + "<br><br>"
					);
				}
						
/**display to body**/
				
			});
				
		});
	
		});
	});
	
	function addCommas(nStr){
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	}
</script>
</head>
<body> 

<?php 
	include"template/$header.php"; 

	include("query/db_connection.php");
?>
  <div class='clear'></div>
<!-- start content-outer ........................................................................................................................START -->
	<div id='content-outer'>
	<!-- start content -->
	<div id='content'>

	<!--  start page-heading -->
	<div id='page-heading'>
		<h1>Royal American Limousine Rates Information</h1>
	</div>
	<!-- end page-heading -->

	<table border='0' width='100%' cellpadding='0' cellspacing='0' id='content-table'>
	<tr>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowleft.jpg' width='20' height='300' alt='' /></th>
		<th class='topleft'></th>
		<td id='tbl-border-top'>&nbsp;</td>
		<th class='topright'></th>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowright.jpg' width='20' height='300' alt='' /></th>
	</tr>
	<tr>
		<td id='tbl-border-left'></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id='content-table-inner'>
			<!--  start table-content  -->
			<div id="result" style="min-height: 250px; position: relative;">
				<div class='result-header'></div>
				</br>
				<div class='result-body' style="padding: 10px; font-size: 14px;"></div>
				<div class='result-footer' style="position: absolute; bottom: 0px; right: 300px;"></div>
			</div>
			<!--  end table-content  -->
	
			<div class='clear'></div>
		 
		</div>
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id='tbl-border-right'></td>
	</tr>
	<tr>
		<th class='sized bottomleft'></th>
		<td id='tbl-border-bottom'>&nbsp;</td>
		<th class='sized bottomright'></th>
	</tr>
	</table>
	<div class='clear'>&nbsp;</div>

	</div>
	<!--  end content -->
	<div class='clear'>&nbsp;</div>
	</div>
	<!--  end content-outer........................................................END -->";
				
<!--  start nav-outer-repeat................................................... END -->

  <div class="clear"></div>
 
<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
<!-- start content -->
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->

<div class="clear">&nbsp;</div>
    
<?php include"template/footer.php"; ?>
 
</body>
</html>


